import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n,m,q;
        n = scanner.nextInt();
        m = scanner.nextInt();
        q = scanner.nextInt();
        int[][] arr = new int[n+1][m+1];
        int[][] sum = new int[n+1][m+1];
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= m; j++) {
                arr[i][j] = scanner.nextInt();
            }
        }
        for(int i = 1;i<=n;i++) {
            for(int j = 1;j<=m;j++) {
                sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + arr[i][j];
            }
        }

        while(n-->=0) {
            int x1 = scanner.nextInt();
            int y1 = scanner.nextInt();
            int x2 = scanner.nextInt();
            int y2 = scanner.nextInt();

            int ret = sum[x2][y2] - sum[x1-1][y2] - sum[x2][y1-1] + sum[x1-1][y1-1];
            System.out.println(ret);
        }
    }
}
